package com.example.hrsystem.data.source;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
import androidx.room.Delete;

import com.example.hrsystem.workflow.model.WorkflowTask;

import java.util.List;

@Dao
public interface WorkflowTaskDao {
    @Query("SELECT * FROM workflow_tasks")
    List<WorkflowTask> getAllTasks();

    @Query("SELECT * FROM workflow_tasks WHERE id = :id")
    WorkflowTask getTaskById(int id);

    @Query("SELECT * FROM workflow_tasks WHERE processInstanceId = :processInstanceId")
    List<WorkflowTask> getTasksByProcessInstanceId(int processInstanceId);

    @Query("SELECT * FROM workflow_tasks WHERE assigneeId = :assigneeId")
    List<WorkflowTask> getTasksByAssigneeId(Integer assigneeId);

    @Query("SELECT * FROM workflow_tasks WHERE status = :status")
    List<WorkflowTask> getTasksByStatus(String status);

    @Insert
    void insertTask(WorkflowTask task);

    @Update
    void updateTask(WorkflowTask task);

    @Delete
    void deleteTask(WorkflowTask task);

    @Query("DELETE FROM workflow_tasks")
    void deleteAllTasks();
}